<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>
<body>
  <p>收到b页面的值：<span id="data"></span></p>
  <iframe src="http://child.cross.com:3000/postMessage/b.html" id="iframe"></iframe>
  <script>
    var iframe = document.getElementById('iframe')
    var data = 'aaaaaaaaaaaa'
    iframe.onload = function() {
      iframe.contentWindow.postMessage(data, 'http://child.cross.com:3000')
    }

    window.addEventListener('message', function(msg) {
      document.getElementById('data').innerText = msg.data
    })
  </script>
</body>
</html>